package com.fz.util;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import java.util.Random;

public class FzUtil {
    public static String randomOrderCode(String prefix) {
        String randata = getRandom(6);
        LocalDateTime now = LocalDateTime.now();
        String dateran = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
        String code = prefix + dateran + randata;
        if (code.length() < 24) {
            code = code + 0;
        }
        return code;
    }

    public static String getRandom(int len) {
        Random r = new Random();
        StringBuilder rs = new StringBuilder();
        for (int i = 0; i < len; i++) {
            rs.append(r.nextInt(10));
        }
        return rs.toString();
    }

}
